<?php

class Location extends AppModel {

    var $name = 'Location';
    var $belongsTo = array(
        'Warehouse',
        'User' => array(
            'foreignKey' => 'collector_id',
            'fields' => array('name')
        ),
    );
    var $validate = array(
        'name' => array(
            'notEmpty' => array(
                'rule' => array('notEmpty'),
                'message' => 'Location name is required.',
                'required' => true,
            ),
            'isUnique' => array(
                'rule' => 'isUnique',
                'message' => 'This locations name is already taken.',
            ),
        ),
        'warehouse_id' => array(
            'notEmpty' => array(
                'rule' => array('notEmpty'),
                'message' => 'Warehouse is required.',
                'required' => true,
                'on' => 'create'
            ),
        )
    );

}
